package com.zabra.zl.ui.success;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.zabra.zl.MainActivity;
import com.zabra.zl.R;
import com.zabra.zl.base.BaseActivity;
import com.zabra.zl.data.EventMessage;
import com.zabra.zl.ui.godeal.GoDealActivity;
import com.zabra.zl.ui.personal_center.PersonalActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class VerifyPersonSuccessActivity extends BaseActivity {


    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_complete)
    TextView tvComplete;
    private String strMessage;

    @Override
    public int getLayoutId() {
        return R.layout.activity_verify_person_success;
    }

    @Override
    protected void onStart() {
        super.onStart();
        EventBus.getDefault().register(this);
    }

    @Override
    public void initView() {
        tvTitle.setText("操作提示");
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onReceiveMsg(EventMessage message) {
        strMessage = message.getMessage();
    }

    @OnClick({R.id.back, R.id.tv_complete})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                if (strMessage.equals("Person")) {
                    toClass_EmptyTop(this, PersonalActivity.class);
                }
                if (strMessage.equals("Main")) {
                    toClass_EmptyTop(this, MainActivity.class);
                }
                if (strMessage.equals("Deal")) {
                    toClass_EmptyTop(this, GoDealActivity.class);
                }

                break;
            case R.id.tv_complete:
                if (strMessage.equals("Person")) {
                    toClass_EmptyTop(this, PersonalActivity.class);
                }
                if (strMessage.equals("Main")) {
                    toClass_EmptyTop(this, MainActivity.class);
                }
                if (strMessage.equals("Deal")) {
                    toClass_EmptyTop(this, GoDealActivity.class);
                }
                break;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (strMessage.equals("Person")) {
                toClass_EmptyTop(this, PersonalActivity.class);
            }
            if (strMessage.equals("Main")) {
                toClass_EmptyTop(this, MainActivity.class);
            }
            if (strMessage.equals("Deal")) {
                toClass_EmptyTop(this, GoDealActivity.class);
            }
        }
        return true;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
